package models

//ResultCode 返回码接口
type ResultCode interface {
	Desc() string
	Code() int
}

//定义公共返回码
const (
	RC_MISS_PARAM RcCommon = 5001
	RC_VALID_FAIL RcCommon = 5002
	RC_NO_SERVER RcCommon = 5003
	RC_SIGN_FAIL RcCommon = 5004
	RC_NO_ACCOUNT RcCommon = 5005
	RC_NO_MONEY RcCommon = 5006
	RC_NO_IP RcCommon = 5007
	RC_UNKNOWN RcCommon = 5555
)

var (
	commonDesc = map[ResultCode]string{
		RC_MISS_PARAM: "缺少必须参数",
		RC_VALID_FAIL:  "参数校验失败",
		RC_NO_SERVER:   "没有开通服务",
		RC_SIGN_FAIL:   "签名校验失败",
		RC_NO_ACCOUNT:  "账户没有开通",
		RC_NO_MONEY:    "账户余额不足",
		RC_NO_IP:    "该ip没有访问权限",
		RC_UNKNOWN:      "未知异常",
	}
)
//公用返回码
type RcCommon int

func (this RcCommon) Desc() string {
	return commonDesc[this]
}

func (this RcCommon) Code() int {
	return int(this)
}
